package casbinApi

import (
	"github.com/Sir-yuChen/funAnalyse/model"
	"github.com/Sir-yuChen/funAnalyse/model/common/response"
	"github.com/Sir-yuChen/funAnalyse/utils"
	"github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/binding"
)

type StockCasbinRoleController struct{}

// GetStockCasbinRole 多条件查询
// @Summary stockCasbinRole get
// @Tags casbin
// @Accept application/json
// @Produce application/json
// @Param data body model.StockCasbinRoleModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/casbin/getCasbinRole [GET]
func (b *StockCasbinRoleController) GetStockCasbinRole(c *gin.Context) {
	var req model.StockCasbinRoleModel
	err := c.ShouldBindJSON(&req)
	if err != nil {
		utils.ErrValidatorResp(err, "GetStockCasbinRole", req, c)
		return
	}
	apiReturn := stockCasbinRoleService.GetStockCasbinRole(&req)
	response.WithApiReturn(apiReturn, c)
	return
}

// InsertStockCasbinRole
// @Summary stockCasbinRole insert
// @Tags casbin
// @Accept application/json
// @Produce application/json
// @Param data body model.StockCasbinRoleModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/casbin/insertCasbinRole [POST]
func (b *StockCasbinRoleController) InsertStockCasbinRole(c *gin.Context) {
	var req model.StockCasbinRoleModel
	err := c.ShouldBindBodyWith(&req, binding.JSON)
	if err != nil {
		utils.ErrValidatorResp(err, "InsertStockCasbinRole", req, c)
		return
	}
	apiReturn := stockCasbinRoleService.InsertStockCasbinRole(&req, c)
	response.WithApiReturn(apiReturn, c)
	return
}

// UpdateStockCasbinRole
// @Summary stockCasbinRole update
// @Tags casbin
// @Accept application/json
// @Produce application/json
// @Param data body model.StockCasbinRoleModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/casbin/updateCasbinRole [POST]
func (b *StockCasbinRoleController) UpdateStockCasbinRole(c *gin.Context) {
	var req model.StockCasbinRoleModel
	err := c.ShouldBindBodyWith(&req, binding.JSON)
	if err != nil {
		utils.ErrValidatorResp(err, "UpdateStockCasbinRole", req, c)
		return
	}
	apiReturn := stockCasbinRoleService.UpdateStockCasbinRole(&req)
	response.WithApiReturn(apiReturn, c)
	return
}

// DelStockCasbinRole
// @Summary stockCasbinRole del
// @Tags casbin
// @Accept application/json
// @Produce application/json
// @Param data body model.StockCasbinRoleModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/casbin/delCasbinRole [Get]
func (b *StockCasbinRoleController) DelStockCasbinRole(c *gin.Context) {
	var req model.StockCasbinRoleModel
	err := c.ShouldBindBodyWith(&req, binding.JSON)
	if err != nil {
		utils.ErrValidatorResp(err, "DelStockCasbinRole", req, c)
		return
	}
	apiReturn := stockCasbinRoleService.DelStockCasbinRole(&req)
	response.WithApiReturn(apiReturn, c)
	return
}
